package org.wutopia.labcloud.domain.uaa.controller;

import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.wutopia.labcloud.domain.uaa.controller.vo.input.UserAddressCreateInputVO;
import org.wutopia.labcloud.domain.uaa.controller.vo.output.UserAddressGetListOutputVO;
import org.wutopia.labcloud.domain.uaa.service.UserAddressService;
import org.wutopia.labcloud.library.common.base.CodedMessage;
import org.wutopia.labcloud.library.common.base.CommonResponse;

@RestController
@AllArgsConstructor
@Slf4j
@RequestMapping("/user/address")
public class UserAddressController {

    private UserAddressService userAddressService;

    @GetMapping("/list")
    public ResponseEntity<CodedMessage<UserAddressGetListOutputVO>> getList(@RequestParam Long userId) {

        UserAddressGetListOutputVO lIst = userAddressService.getLIst(userId);

        return CommonResponse.successWithData(lIst);
    }

    @PostMapping("/create")
    public ResponseEntity<CodedMessage<String>> createAddr(@RequestBody UserAddressCreateInputVO vo) {

        userAddressService.create(vo);

        return CommonResponse.success();
    }

    @PostMapping("/delete")
    public ResponseEntity<CodedMessage<String>> delete(@RequestBody Long userAddrId) {

        userAddressService.delete(userAddrId);

        return CommonResponse.success();
    }

}
